package com.lagou;

import com.lagou.service.CallStudentService;
import com.lagou.vo.Student;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConsumerApplication.class)
public class test {

    @Autowired
    private CallStudentService callStudentServiceImpl;

    @Test
    public void testStudentCall() throws Exception {
        while(true){
            try {
                Student student = callStudentServiceImpl.getStudent();
                System.out.println(student.getName());
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    @Test
    public void testBlog(){
            callStudentServiceImpl.getBlogTitle();
    }
//    @Test
//    public void testClient() throws Exception{
//        //1.创建代理对象
//        //IUserService service = (IUserService) RpcConsumerV2.createProxy(IUserService.class);
//
//        //2.循环给服务器写数据
////        while (true){
////            String result = service.sayHello("are you ok !!");
////            System.out.println(result);
////            Thread.sleep(2000);
////        }
//        String result = service.sayHello("are you ok !!");
//        System.out.println(result);
//    }
//
//    @Test
//    public void testStudent() throws Exception{
//        IStudentService service = (IStudentService)RpcConsumerV2.createProxy(IStudentService.class);
//        while(true){
////            System.out.println("客户端执行findAllStudents方法：");
////            List<Student> studentList = service.findAllStudents();
////            for (Student student : studentList) {
////                System.out.println("客户端收到findAllStudents结果："+student.toString());
////            }
//            System.out.println("客户端执行findOneStudent方法：");
//            Student oneStudent = service.findOneStudent("123");
//            System.out.println("客户端收到findOneStudent结果："+oneStudent.toString());
//
//            System.out.println("客户端执行updateStudent方法：");
//            service.updateStudent("123");
//            System.out.println("客户端执行updateStudent成功");
//            Thread.sleep(5000);
//        }
//
//    }
}
